package com.android.filter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.android.filter.Frame.FrameInterface;
import com.android.filter.LauncherFrameLayout.LayoutInterface;
import com.example.plasma.R;

public class Launcher extends FrameStatus implements FrameInterface{
	
	
	public Launcher(Context context)
	{
		super();
		mContext = context;
		LauncherFrameLayout layout = (LauncherFrameLayout)((Activity)mContext).findViewById(R.id.launch_frame_layout);
		layout.setOnLayoutInterface(new LayoutInterface() {
			
			public void onLayoutCallback(boolean changed, int left, int top, int right,
					int bottom) {
				if(true)
				{
					int width = right - left;
					int height = bottom - top;
					MyButton select = (MyButton)((Activity)mContext).findViewById(R.id.select_picture_button);
					select.changeButtonSize(width, height);
					select.changePosition(0, height * .7f);
				}
			}

		});
		Button selectButton = (Button)((Activity)mContext).findViewById(R.id.select_picture_button);
		selectButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_PICK);
				intent.setType("image/*");
				intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.CONTENT_TYPE);
				((Activity)mContext).startActivityForResult(intent, 0);
			}
		});
	}
	public void setChangeStatusCallback(ChangeStatusCallback callback) {
		mChangeStatusCallback = callback;
	}

	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	public void configurationChanged() {
		// TODO Auto-generated method stub
		
	}
	private Context mContext = null;
	public void backPressed() {
		mChangeStatusCallback.changeStatus(Frame.KILL);
	}
}
